<%@ page import="zzc.javaWeb.javaWebHomew.pojo.PageBean" %>
<%@ page import="java.util.List" %>
<%@ page import="zzc.javaWeb.javaWebHomew.pojo.UserBean" %>
<%@ page import="zzc.javaWeb.javaWebHomew.dao.homeDaoimp" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="zzc.javaWeb.javaWebHomew.utill.DBUTill" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%--Created by IntelliJ IDEA.--%>
<%--  User: ZhangZaichen--%>
<%--  Date: 2021/6/13--%>
<%--  Time: 15:35--%>
<%--  To change this template use File | Settings | File Templates.--%>
<%--&ndash;%&gt;--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html >
<head>

    <meta charset="utf-8" />
    <title>抢课系统</title>
    <style type="text/css">

        *{
            margin: 0;
            padding: 0;
            font-size: 1rem;
        }
        body{

            background-image: url("https://i.loli.net/2021/05/22/YDU8jLeolX2FyEn.jpg");
            background-repeat: repeat;
            background-position: right;
        }
        #container{
            padding: 10px;
            margin: 0 auto;
            width: 80%;
            height: 100%;
        }
        .top{
            background:black;
            color: white;
            padding: 10px;
            font-size: 1.25rem;
            font-weight: bold;
        }
        .nav{
            background:#6e6767;
            padding: 1.25rem;
        }
        .conter{
            padding: 20px 7%;
            background-color:#ffffff;
        }
        .conter_up{
            text-decoration: none;
            color: #9292ee;
            font-size: 1rem;
            font-weight: bold;
            letter-spacing: 0.2rem;
            padding-bottom: 20px;
        }
        .conter_middle table{
            border: 1px solid ;
            text-align: center;
            width: 100%;
            font-size: 1.5rem;
            letter-spacing: 0.1rem;
            border: 2px solid black;
        }
        .conter_middle td,th{
            border: 1px solid #6e6767;
            height: 45px;
        }
        .conter_middle a{
            text-decoration: none;
            font-weight: bold;
        }
        .conter_down{
            display: flex;
            justify-content: flex-end;
            padding: 20px;
        }
        .conter_down>*{
            margin-right: 8px;
        }
        .foot{

            padding: 20px;
            color: white;
            display: flex;
            justify-content: center;
        }
    </style>
</head>
<body>
<div id="container">
    <div class="top">
        高校期末题目抢选系统
    </div>
    <div class="nav">
        <a href="home.jsp" style="color: black">首页</a>
        <a href="inputMes.html" style="color: black">课题录入</a>
        <a href="stuLogin.html" style="color: black">学生端入口</a>


    </div>
    <div class="conter">
        <div class="conter_up">
            高校期末课题抢选系统（管理员端）
        </div>
        <div class="conter_middle">
            <table cellspacing="0" cellpadding="0">
                <thead>
                <tr>
                    <th>题号</th>
                    <th>题目</th>
                    <th>剩余</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <%
                    int nowpage =0;
                    int meiyexianshi=10;
                    int zongtiaoshu=0;

                    //new对象
                    DBUTill  dbuTill = new DBUTill();
                    PageBean pBean = new PageBean();
                    homeDaoimp homeDaoimp = new homeDaoimp();
                    int zongshu=homeDaoimp.findTotalCount(); //总计数
                    //分页
                    String n =  request.getParameter("n");

                    int pageCount=0;


                    if (n!=null)
                    {
                        nowpage = Integer.parseInt(n);
//                        if (nowpage<=0) {
//                            pBean.setDangPage(0);
//                            nowpage=0;
//                            pBean.setMeiPages(meiyexianshi);
//                        }
//                        if (nowpage>=pageCount){
//                            pBean.setDangPage(pageCount);
//                            nowpage=pageCount;
//                            pBean.setMeiPages(5);
//                        }
//                    }
//
//                    else {
//                        nowpage=0;
//                        pBean.setDangPage(0);
//                        pBean.setMeiPages(5);
                    }
                    pageCount = zongshu%meiyexianshi ==0? zongshu/meiyexianshi:zongshu/meiyexianshi+1;
                    if (nowpage<=0){
                        nowpage=1;
                    }
                    if (nowpage>=pageCount){
                        nowpage=pageCount;
                    }
                    Connection connection = dbuTill.connectDataSource();
                    String sql ="select*from homeuser limit ?,?";
                    PreparedStatement pt = connection.prepareStatement(sql);
                    pt.setInt(1,meiyexianshi*(nowpage-1));
                    pt.setInt(2,meiyexianshi);
                    ResultSet rs = pt.executeQuery();

                    while (rs.next()){


                %>
                <tr>


                        <td><%=rs.getInt("id")%></td>
                        <td><%=rs.getString("timu")%></td>
                        <td><%=rs.getInt("yuliang")%></td>
                        <td><a href="/Jer/del.jsp?id=<%=rs.getInt("id")%>&keti=<%=rs.getString("timu")%>&yuliang=<%=rs.getInt("yuliang")%>">删除课题</a> <a href="/Jer/update.jsp?id=<%=rs.getInt("id")%>&keti=<%=rs.getString("timu")%>&yuliang=<%=rs.getInt("yuliang")%>">修改课题</a></td>
                        <%}%>


                </tr>

                </tbody>
            </table>
        </div>
        <div class="conter_down">
            <div>
                <span>总条数<%=zongshu%></span>
                <a href="home.jsp">首页</a>
                <a  href="home.jsp?n=<%=nowpage-1%>">上页</a>
                <a href="home.jsp?n=<%=nowpage+1%>">下页</a>
            </div>

        </div>
    </div>
    <div class="foot">
        &copy;Created by 琛.
    </div>
</div>
<script>

</script>
</body>
</html>
